GS-Calc Help > Calculation Functions > Output Functions

Function Index

imageIf messageIf playSoundIf setFormatIf

Output Functions


imageIf(if_condition, path_true, path_false, type)

Displays an image in a cell (overflowing cell boundaries if necessary).

if_condition:
If non‑zero, path_true is displayed; otherwise path_false.

path_true / path_false:
Image file paths or names.

The list of inserted images can be managed via the Set Cell Background Image toolbar button or the Cell Style Properties dialog.

type: Determines how paths are interpreted.

Images are drawn immediately after formula evaluation is complete.

=imageIf(P251 > 0, "e:\image_file1.png", "e:\image_file2.png", 1)

=imageIf(S10:S120 = 0, "folder1\music_file1.jpg", "image_file2.gif", 0)


messageIf(message, type, if_condition, reference-as-text)

Displays a message box with OK and Cancel.

message: Text to display.

type:

if_condition:
Message appears only if the condition evaluates to non‑zero.

reference (as text):
Optional full worksheet path. If provided and you click OK, GS-Calc jumps to the referenced cell/range.

Messages appear immediately after formula evaluation is complete. You can use if_condition = 1 to signal the end of updating.

=messageIf("need to inspect this cell", 1, isError(folder2\sheet2!P251), "folder2\sheet2!P251")

=messageIf("need to inspect this cells", 1, isError(S120), "S121:S200")


playSoundIf(path, type, if_condition, loops, volume)

Plays MP3 and WAV files.

path:
File path.

type: Determines how the path is interpreted.

if_condition: File plays only if non‑zero.

loops:
Number of times to play. -1 = endless loop.

volume:
Value from 0 to 1000.

Files play immediately after formula evaluation is complete. Use if_condition = 1 to signal the end of updating.

If multiple files are queued, they play sequentially.

To stop playback, press ESC or use Tools > Cancel Update.

=playSoundIf("e:\music_file1.mp3", 1, true, 1, 40)

=playSoundIf("folder1\music_file1.mp3", 0, true, 100, 80)


setFormatIf(reference, action, if_condition, format_true, format_false)

This function formats a cell or range of cells. The numeric action parameter specifies which formatting attributes to set or clear (restore defaults).

It is often convenient to keep formatting formulas in a separate worksheet so a single control cell can affect formatting across multiple sheets.

The function works on both existing cells and empty regions. There are no limits on the number or complexity of conditional formatting operations — millions of cells may be formatted using nested IFs or other formulas.

Formatting Layers

If reference specifies entire columns or rows, formatting applies to column or row styles. Formatting precedence:

table style < column styles < row styles < cell styles

Cell styles override all other styles.

format_true / format_false Values

Values may be -1 (restore default) or one of the following:

Custom Cell Styles

action = 32 applies all formatting attributes using a named custom style. Custom styles are created in Format > Custom Cell Styles and saved in the workbook.

They may also be saved to or loaded from the global GS-Calc cache using:

Border Formatting (action = 20)

position may include:

  • top
  • left
  • bottom
  • right
  • diag-left
  • diag-right

width may be:

  • thin, medium, thick
  • numeric values with px, pt, in, mm, cm, pc

style may be:

  • solid
  • dotted
  • dash
  • long-dash
  • dot-dash
  • dot-dot-dash
  • wave
  • double

color may be an RGB value, “#RRGGBB”, or one of:

  • black
  • maroon
  • green
  • olive
  • navy
  • purple
  • teal
  • gray
  • silver
  • red
  • lime
  • yellow
  • blue
  • fuchsia
  • aqua
  • white

Return Value

The function returns the evaluated value of if_condition.

=setFormatIf(c120, 11, c120 > 0, "green", "red")

=setFormatIf(c:e, 11, c120 > 0, "green", "red")

=setFormatIf(10:20, 11, c120 > 0, "green", "red")

=setFormatIf(c120, 20, c120 > 0, "all 2px solid green", "diag-left diag-right red")

=setFormatIf(d100:d999, 1, c1="use format", "currency", 0)

=setFormatIf(d99, 20, a1, "bottom 2px dotted green", -1)

=setFormatIf(d99, 32, a10 > 10, "my-style-1", "my-style-2")